module(
    name = "hermetic_cc_toolchain",
    version = "4.0.0",
)

bazel_dep(name = "bazel_features", version = "1.21.0")
bazel_dep(name = "platforms", version = "0.0.10")

bazel_dep(name = "rules_go", version = "0.54.0", dev_dependency = True)

go_sdk = use_extension(
    "@rules_go//go:extensions.bzl",
    "go_sdk",
    dev_dependency = True,
)
use_repo(go_sdk, "go_default_sdk")

bazel_dep(name = "gazelle", version = "0.43.0", dev_dependency = True)

go_deps = use_extension(
    "@gazelle//:extensions.bzl",
    "go_deps",
    dev_dependency = True,
)
go_deps.from_file(go_mod = "//:go.mod")
use_repo(
    go_deps,
    "com_github_bazelbuild_buildtools",
    "com_github_stretchr_testify",
    "com_github_tetratelabs_wazero",
)

toolchains = use_extension("//toolchain:ext.bzl", "toolchains", dev_dependency = True)
use_repo(toolchains, "zig_sdk")

# TODO: register all toolchains by:
# `register_toolchains("@zig_sdk//...")`
# when `hermetic_cc_toolchain` supports MacOS SDK
# https://github.com/uber/hermetic_cc_toolchain/issues/10
register_toolchains(
    "@zig_sdk//toolchain:linux_amd64_gnu.2.28",
    "@zig_sdk//toolchain:linux_arm64_gnu.2.28",
    "@zig_sdk//toolchain:windows_amd64",
    "@zig_sdk//toolchain:windows_arm64",

    # amd64 toolchains for libc-aware platforms:
    "@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.28",
    "@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.31",
    "@zig_sdk//libc_aware/toolchain:linux_amd64_musl",

    # arm64 toolchains for libc-aware platforms:
    "@zig_sdk//libc_aware/toolchain:linux_arm64_gnu.2.28",
    "@zig_sdk//libc_aware/toolchain:linux_arm64_musl",

    # wasm/wasi toolchains
    "@zig_sdk//toolchain:wasip1_wasm",

    # zig toolchains
    "@zig_sdk//toolchain:zig",
    dev_dependency = True,
)
